package com.lvyuely.common.web.core.pojo;

import java.util.List;

/**
 * 分页工具类
 * <pre>
 * <b>项目</b> :  member-center-base
 * <b>包名</b> :  glodon.gcj.member.center.pojo
 * <b>类名</b> :  Page
 * <b>描述</b> :
 * <b>版权</b> :  Copyright (c) 1999-2014 广联达软件股份有限公司
 * </pre>
 *
 * @author :   lvyue
 * @version :  1.0
 * @date :     14/11/19 19:00
 */
public class Page<T> {

    private List<T> dataList;

    private int current;// 分页当前页

    private int pages;//分页总页数

    private int size = 20;//分页每页条数

    private long total;//纪录总数

    private int start;

    public int getStart() {
        return start;
    }

    public void setStart(int start) {
        this.start = start;
    }

    public void calc() {
        pages = (int) (total % size == 0 ? total / size : total / size + 1);
        if (current > pages) {
            current = pages;
        }
        if (current <= 0) {
            current = 1;
        }
        start = (current - 1) * size;

    }

    public List<T> getDataList() {
        return dataList;
    }

    public void setDataList(List<T> dataList) {
        this.dataList = dataList;
    }

    public int getCurrent() {
        return current;
    }

    public void setCurrent(int current) {
        this.current = current;
    }

    public int getPages() {
        return pages < 1 ? 1 : pages;
    }

    public void setPages(int pages) {
        this.pages = pages;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        if (size <= 0) {
            size = 20;
        }
        this.size = size;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }


}
